#pragma once

#include <list>
#include "SceneNode.h"
#include "ScenePosRef.h"
#include "D3D9Engine.h"


class CGameClass;
class CSceneGraph
{
	private:
		CD3D9Engine*				_ptrEngine;
		std::list<CSceneNode*>*		_nodes;


		bool		_addedNodeLastFrame;
		bool		_sortSceneNodes;
		bool		_debugNodeBB;
		RECT		_renderArea;


		void RenderNode(CSceneNode* node, CSceneNode* ref);
		D3DXMATRIX CalculateNodeTransformation(CSceneNode* node, bool traverse);

		void DrawNodeBoundingBox();

	public:
		CSceneGraph(CD3D9Engine* ptrEngine);
		~CSceneGraph();


		CSceneNode* AddNodeToScene(char* nodeName, CSceneNode* node);
		CSceneNode* RemoveNodeFromScene(CSceneNode* node);
		
		CSceneNode* GetNodeByName(char* name);
		CSceneNode* GetNodeByID(int id);
		int	GetSceneNodeCount();


		void ClearScene();
		void ClearSceneAndDelete();


		void RenderScene();
		void UpdateScene(float stepping);

};
